import i18n from "@/locals";
import { ref } from "vue";
/**筛选按钮的key */
enum keyType {
    NONE = 0,
    UP = 1,
    DOWN = 2
}
/**筛选按钮的Item对象 */
interface Item {
    name: string;
    value: keyType;
}

const items = ref(["California", "Colorado", "Florida", "Georgia", "Texas", "Wyoming"]);
const titles = ref([
    {
        // name: '交易对',
        name: i18n.global.t("message.TableF.a"),
        value: keyType.NONE,
        key: "symbol",
        flex: 4
    },
    {
        // name: '最新价',
        name: i18n.global.t("message.TableF.b"),
        value: keyType.NONE,
        key: "lastPrice",
        flex: 3
    },
    {
        // name: '涨跌',
        name: i18n.global.t("message.TableF.c"),
        value: keyType.NONE,
        key: "priceChangePercent",
        flex: 2
    },
    {
        // name: '成交额',
        name: i18n.global.t("message.TableF.d"),
        value: keyType.NONE,
        key: "quoteVolume",
        flex: 3
    }
]);

const iptDown = function (item: any) {
    // console.log("yzt", item);
};

const setType = function (item_: Item) {
    titles.value.forEach(item => {
        if (item.name === item_.name) {
            //在这里拿到筛选的那个key
            // console.log('yzt', item_);
            switch (item.value) {
                case keyType.UP:
                    item.value = keyType.DOWN;
                    break;
                case keyType.NONE:
                    item.value = keyType.UP;
                    break;
                case keyType.DOWN:
                    item.value = keyType.NONE;
                    break;
            }
        } else {
            item.value = keyType.NONE;
        }
    });
};

export { titles, items, setType, iptDown, keyType };
